<html>
	<head>
		<script src="https://s3.amazonaws.com/stitch-sdks/js/bundles/4.8.0/stitch.js"></script>
	</head>
<body>

	<div id="message"></div>
	<script>
		const {
		  Stitch,
		  UserPasswordAuthProviderClient
		} = stitch;

		const APP_ID = "arcanum-yrpin";
		const stitchClient = Stitch.initializeDefaultAppClient(APP_ID);

		const emailPasswordClient = stitchClient.auth
		  .getProviderClient(UserPasswordAuthProviderClient.factory );

		const params = new URLSearchParams(window.location.search);
		const token = params.get('token');
		const tokenId = params.get('tokenId');

		emailPasswordClient
		  .confirmUser( token, tokenId )
		  .then(() => displayResult('success'))
		  .catch(err => displayResult('error', err))

		function displayResult(result, err) {
		  const message = document.getElementById("message");
		  if (result === "success") {
			message.innerText = "Successfully confirmed user. You may close this page.";
		  }
		  else if (result === "error") {
			message.innerText = "Unable to register user.\n\n" + err;
		  }
		}
	  </script>

</body>

</html>